1. The Field of the Invention
The present invention relates to systems and methods for providing multi-pass rendering of three-dimensional graphics. More specifically, the present invention is directed to systems and methods for utilizing one or more texture units and a plurality of associated frame buffers in a rendering pipeline to perform multiple rendering passes, to support the use and storage of extra temporary data, and to blend data from multiple texture maps that is applied to a polygon so as to model a three-dimensional object.
2. Relevant Technology
Adding realism to computer graphics involves rendering an object that has three-dimensional characteristics on a two-dimensional display device. Such three-dimensional characteristics include shadows and variations in color and shade of the object. For each desired three-dimensional characteristic, a specific texture map is applied to a frame of polygons in order to render the object. When multiple characteristics are desired, the corresponding texture maps are blended. Therefore, the blending and applying of various corresponding texture maps renders the object as having the desired three-dimensional characteristics, such as any desired color, pattern, appearance, etc.
A conventional technique for applying multiple texture maps to render a three-dimensional image includes utilizing a single texture unit and a single frame buffer. As multiple passes are performed, the frame buffer is used as the temporary data storage between passes. While such a technique adequately applies light or shadow maps on opaque objects, the conventional technique cannot be adequately utilized for transparent objects since temporary data and current destination pixel data cannot co-exist under the conventional technique.
Another technique for applying multiple texture maps to render a three-dimensional image uses a rendering pipeline that includes a texture unit for every texture map that is applied. The texture units are placed in series within the rendering pipeline, which assembles one or more polygons to represent an object having three-dimensional characteristics and applies multiple texture maps to the assembled polygon. Many effects are only renderable if one or more temporary pieces of data are allowed to exist between texture units of a pipeline. Thus, under this conventional technique, an additional piece of temporary data is passed between the texture units of the rendering pipeline and is fully consumed by the end of the pipeline.
By way of example, FIG. 1 illustrates a conventional rendering pipeline that includes vertex unit 10, setup unit 11, edge walk unit 12, span walk unit 13, z-buffer 14, texture units 15, destination blender 18, and frame buffer 19. In the rendering pipeline, vertex unit 10 assembles data describing the values at each vertex of a polygon. The data includes three-dimensional coordinates, which represent each of the polygons that together model a three-dimensional object, and texture coordinates, the values for which are determined later in the pipeline through a series of texture units. Vertex unit 10 provides the assembled data to setup unit 11, which generates parametric function coefficients for an interpolation of intermediary points between the three-dimensional coordinates. Edge walk unit 12 receives the output of setup unit 11 and determines the starting pixel and the value of the starting pixel for each horizontal row of pixels lying within the bounds of the polygon. Span walk unit 13 then determines the values for all of the pixels for each horizontal row within the polygon. The values determined by edge walk unit 12 and span walk unit 13 are provided to z-buffer 14, which determines whether the pixels are occluded or visible, so that only currently visible pixels are drawn.
A set of texture coordinates representing the various layers of textures that are to be applied to the generated polygons are passed through a series of texture units 15. The number of texture units in series corresponds to the number of texture layers that are to be applied. In the example of FIG. 1, five texture layers are applied to the generated polygons. Other conventional rendering pipelines may include any number of texture units in series to apply the corresponding number of texture maps.
In FIG. 1, each texture unit 15 receives a series of texture coordinate sets for each pixel, performs a texture map look up to obtain the values of the coordinate sets related to a texture map, and performs a blending operation that may include blending the obtained values with values from one or more previous texture maps. Temporary data is passed between the texture units 15 and is fully consumed by the end of the rendering pipeline.
Therefore, with reference to the series of texture units 15 of FIG. 1, texture unit 15a receives a series of texture coordinate sets from z-buffer 14 for each pixel. An example of a series of texture coordinate sets for a given pixel is (u0, v0), (u1, v1), (u2, v2), (u3, v3), and (u4, v4), where (u0, v0) is the texture coordinate set for the first texture map, (u1, v1) is the texture coordinate set for the second texture map, (u2, v2) is the texture coordinate set for the third texture map, (u3, v3) is the texture coordinate set for the fourth texture map, and (u4, v4) is the texture coordinate set for the fifth texture map. Because the texture units are in series, the fill complement of texture coordinate sets, which, in this example include (u0, v0), (u1, v1), (u2, v2), (u3, v3), and (u4, v4), are transmitted from z-buffer to texture unit 15a. In this manner, each of the texture units 15a-15e can select the texture coordinate set it needs to perform a texture map look up operation.
The following example illustrates the conventional technique that is currently performed for each pixel. Texture unit 15a takes the texture coordinate set (u0, v0) corresponding to the first texture map and performs a look up at texture cache 16a to obtain the texture values for the pixel. Texture blender 17a performs a blending operation to apply the texture values to the pixel corresponding to the first texture map.
Texture unit 15b receives the series of texture coordinate sets for the pixel from texture unit 15a. The texture coordinate set (u1, v1), which corresponds to the second texture map, is selected by texture unit 15b and a look up is performed at texture cache 16b to obtain the texture values for the pixel. Texture blender 17b then performs a blending operation, which includes blending the texture values corresponding to texture coordinates (u0, v0) and (u1, v1), to apply the texture values to the pixel corresponding to the first and second texture maps.
Texture unit 15c receives from texture unit 15b the series of texture coordinate sets for the pixel. The texture coordinate set (u2, v2), which corresponds to the third texture map, is selected by texture unit 15c and a look up is performed at texture cache 16c to obtain the texture values for the pixel. Texture blender 17c performs a blending operation, which includes blending the texture values corresponding to texture coordinates (u0, v0), (u1, v1) and (u2, v2), to apply the texture values to the pixel corresponding to the first, second and third texture maps.
Texture unit 15d receives the series of texture coordinate sets for the pixel from texture unit 15c. The texture coordinate set (u3, v3), which corresponds to the fourth texture map, is selected by texture unit 15d and a look up is performed at texture cache 16d to obtain the texture values for the pixel. Texture blender 17d performs a blending operation, which includes blending the texture values corresponding to texture coordinates (u0, v0), (u1, v1), (u2, v2) and (u3, v3), to apply the texture values to the pixel corresponding to the first, second, third, and fourth texture maps.
Texture unit 15e receives the series of texture coordinate sets for the pixel from texture unit 15d. The texture coordinate set (u4, v4), which corresponds to the fifth texture map, is selected by texture unit 15e and a look up is performed at texture cache 16e to obtain the texture values for the pixel. Texture blender 17e performs a blending operation, which includes blending the texture values corresponding to texture coordinates (u0, v0), (u1, v1) (u2, v2), (u3, v3) and (u4, v4), to apply the texture values to the pixel corresponding to the first, second, third, and fourth texture maps.
The process explained above is performed for each of the pixels and the composite texture values, which are the blended texture values for each pixel corresponding to texture coordinates (u0, v0), (u1, v1), (u2, v2), (u3, v3) and (u4, v4). After texturing, the pixels are optionally modified by the destination blender 18, which applies optional fog blending, iterated specular blending, and/or alpha blending to the pixels that are then mapped to a frame buffer 19. Once the completed values for all of the pixels are mapped to frame buffer 19, the display device is refreshed with the rendered image.
Another conventional technique for applying multiple texture maps to render a three-dimensional image utilizes a rendering pipeline, such as the rendering pipeline illustrated in FIG. 1, and an extra piece of temporary data that only exists between texture stages. However, with this technique it is possible for the regular multi-texturing type of temporary data to concurrently exist between texture stages since previous texture stages could have other texture lookup proceeding. As such, there are up to two pieces of temporary inter-texture stage data and one piece of destination pixel data in the frame buffer.
Due to significant and sometimes prohibitive amounts of computing resources that are required, including a high demand for memory, conventional rendering techniques are limited to typically two or three texture units rather than the maximum number of eight. As such, the conventional techniques only allow for three stages of multi-texturing and the conventional techniques are limited to one pass through the rendering pipeline unless no extra temporary data is required after each pass, the pixels are opaque, and there is no pixel discarding occurring during each texture stage (e.g. color keying).
The present invention relates to systems and methods for providing multi-pass rendering of three-dimensional graphics. More specifically, the present invention is directed to systems and methods for utilizing one or more texture units and a plurality of associated frame buffers in a rendering pipeline to perform multiple rendering passes, to support the use and storage of extra temporary data and to blend data from multiple texture maps that is applied to a polygon so as to model a three-dimensional object.
Implementation of the present invention includes using a rendering pipeline having one or more texture units and one or more frame buffers to accommodate the application of multiple textures maps onto primitives. The primitives are typically polygons, and usually triangles, that are used to model a three-dimensional object. The values of various parameters used in the rendering process are defined at the vertices of the polygons. These parameters can include {x, y, z, 1/w, xcex1, R, G, B, and ui, vi}, where u and v represent the coordinates of a texture map that is applied to the vertex. Multiple textures can be applied to a given triangle and i represents the texture map number that is applied to the polygon.
In contrast to the processes performed by conventional rendering pipelines, the present invention uses one or more texture units and one or more frame buffers to apply multiple texture maps in multiple rendering passes, including supporting destination pixel data and temporary data. As such, implementation of the present invention includes, for example, the ability to read from two frame buffers and to write to one frame buffer per pixel. Furthermore, each frame buffer can have 32-bit per pixel data split into two 16-bit per pixel pieces of temporary data to allow for the support of up to four pieces of temporary data, including the destination pixel data.
Implementation of the present invention includes the ability to render any number of passes (0-8) with the selection of any texture operation. Thus, the present invention allows for up to the maximum number of eight completely general purpose texture passes, including the bump map and premodulation on any pass.
When a polygon is being rendered, a software driver monitors which texture pass is being performed. For each pixel of a frame, the only texture coordinate set obtained by the texture unit during the first pass is (u0, v0), which relates to a first texture map. The texture unit looks up a texture value from a first texture map in a texture map library. The texture value corresponds to the (u0, v0) texture coordinate set for the pixel, and is stored in a temporary frame buffer.
During a second texture pass for the pixel, the texture unit obtains a texture coordinate set (u1, v1), which relates to a second texture map. The texture unit looks up a texture value from a second texture map in the texture map library. The texture value corresponds to the (u1, v1) texture coordinate set for the pixel. A texture blender blends the texture value of the pixel located in the temporary frame buffer with the texture value obtained during the second pass and stores the composite texture value for the pixel in a second frame buffer. Alternatively, the texture value obtained during the second pass is not blended with the texture value of the first pass, but is rather stored separately in a second temporary frame buffer. Therefore, implementation of the present invention includes supporting the use and/or storage of extra temporary data. Depending on the texture operations chosen, there are up to two pieces of additional temporary data required between each texture pass and can be supported by implementation of the presenting invention. Thus, for example, there may not be any additional temporary data required between passes 1 and 2, however, two additional pieces of temporary data may be required between two other consecutive passes. A driver examines the texture stage state, decides what additional temporary data is required between passes, and executes the necessary procedure.
The process described above is repeated so as to allow a texture pass to be performed for every texture map that is to be applied onto a primitive. Furthermore, the process is performed for every pixel of a frame. Once performed for every texture map and for every pixel, the composite texture values obtained are blended with the destination pixel data stored in a destination frame buffer for all of the pixels of the frame.
Utilization of the invention in rendering a three-dimensional object reduces the amount of computing resources that are required to render the object. The only texture coordinate set provided to the texture unit during each pass is the texture coordinate set for the particular texture map that is being processed in the pass. Therefore, the elimination of redundant texture coordinate sets for each pixel of every frame optimizes the amount of silicon space (i.e. the gates and wires) that is required. An alternative implementation allows for multiple cycles per pixel to be taken and saved on successive iterations. Texture data is run through one or more texture units multiple times for maximal throughput. As such, in the alternative implementation it is still required to store the extra state for the programmer settings of different texture passes.
Therefore, implementation of the present invention utilizes one or more texture units and one or more frame buffers to render a three-dimensional object. The frame buffers include up to two frame buffers that can be read on each pass and one frame buffer that can be written to on each pass. Further, each buffer can have one piece of data or can be xe2x80x9csplitxe2x80x9d so as to contain two pieces of data. As such, the present invention can accommodate the worst case scenario of one piece of destination frame buffer data and two pieces of texture pass temporary data. Further, each texture pass can write a maximum of two pieces of data, temporary or otherwise, so as to allow for one buffer to be sufficient for which to be written. Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention. The features and advantages of the invention may be realized and obtained by means of the instruments and combinations particularly pointed out in the appended claims. These and other features of the present invention will become more fully apparent from the following description and appended claims, or may be learned by the practice of the invention as set forth hereinafter.